package Modelo;

import java.io.Serializable;

import Marca.Marca;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table (name = "tab_modelo")
public class Modelo implements Serializable{
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue (strategy = GenerationType.IDENTITY)
	private Integer codModelo;
	@Column (length = 50)
	private String dscModelo;
	@ManyToOne (fetch = FetchType.EAGER, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
	@JoinColumn
	private Marca marca;
	
	public Modelo() {
		super();
	}

	

	public Modelo(String dscModelo, Marca marca) {
		super();
		this.dscModelo = dscModelo;
		this.marca = marca;
	}



	public Integer getCodModelo() {
		return codModelo;
	}



	public void setCodModelo(Integer codModelo) {
		this.codModelo = codModelo;
	}



	public String getDscModelo() {
		return dscModelo;
	}



	public void setDscModelo(String dscModelo) {
		this.dscModelo = dscModelo;
	}



	public Marca getMarca() {
		return marca;
	}



	public void setMarca(Marca marca) {
		this.marca = marca;
	}



	public static long getSerialversionuid() {
		return serialVersionUID;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((codModelo == null) ? 0 : codModelo.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Modelo other = (Modelo) obj;
		if (codModelo == null) {
			if (other.codModelo != null)
				return false;
		} else if (!codModelo.equals(other.codModelo))
			return false;
		return true;
	}



	@Override
	public String toString() {
		return dscModelo;
	}
	
	
}
